<extend name="Common:sysTemplate" />
<block name="content">
    <script type="text/javascript">
        var apps = new Array();
        var run = 0;
        function testlink() {
            if(apps[run]) {
                $('#status_' + apps[run]).innerHTML = '正在连接...';
                $('#link_' + apps[run])[0].src = $('#link_' + apps[run]).attr('testlink');
            }
            run++;
        }
        window.onload = testlink;
    </script>
    <li><a href="__URL__/add">+添加应用</a></li>
    <form>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_list">
            <thead>
                <tr>
                    <td width="30">ID</td>
                    <td>应用名称</td>
                    <td>应用主URL</td>
                    <td width="90">通信情况</td>
                    <td width="90">详情</td>
                </tr>
            </thead>
            <tbody>
            <volist name="list" id="vo"  key="k">
                <tr align="center" id="{$vo.id}">
                    <td>{$vo.id}</td>
                    <td>{$vo.title}</td>
                    <td>{$vo.url}</td>
                    <td>
                        <div id="status_{$vo.id}"></div>
                        <script id="link_{$vo.id}" testlink="__URL__/ping?appid={$vo.id}"></script>
                        <script>apps[{$k-1}] = '{$vo.id}';</script>
                    </td>
                    <td class="op">
                        <a href="__URL__/edit?id={$vo.id}">编辑</a>
                        <a href="javascript:void(0);" class="delthis">删除</a>
                    </td>            
                </tr>
            </volist>    
            </tbody>
        </table>    
        <input type="hidden" name="act" id="act" />
    </form>
</block>
</block>
<block name="footjs">
    <script type="text/javascript">
        $(function(){
            $(".table_list>tbody>tr:odd").addClass('dbl');

            $('.table_list>tbody>tr').hover(function () {
                if (!$(this).hasClass('ol')) {
                    $(this).addClass('dbh');
                }
            }, function () {
                if (!$(this).hasClass('ol')) {
                    $(this).removeClass('dbh');
                }
            })
            //删除
            $(".delthis").click(function(){
                var obj=$(this);
                $.jBox.confirm("确定删除吗？", "提示", function(v, h, f){
                    var id=$(obj).parents("tr").attr("id");
                    if (v == 'ok') {
                        $.getJSON("__URL__/del", { id:id}, function(json){
                            if(json.status==1){
                                $.jBox.tip(json.info);
                                $(obj).parents("tr").remove();
                            }else{
                                $.jBox.tip(json.info);
                            }
                        });
                    }
                });
        
        
            });
        });
    </script>
</block>